
//
// 101205a- AH - Created.
// 101205b- AH - toString().
//

package org.soekrat.test;

import org.soekrat.engine.visitor.Input;

/**
 * <p>
 *   Base class for Soekrat test cases.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC) 
 */
public abstract class SoekratTestCase 
{
  private final String m_name;
  
  private String m_subcase=null;
  
  private String m_metacase=null;
  
  private Input m_keywords=null;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param name Test case name.
   */
  protected SoekratTestCase(String name)
  {
    if (name==null)
    {
      throw new NullPointerException("name");
    }
    
    m_name=name;
  }
  
  /**
   * <p>
   *   Get test case's name.
   * </p>
   * @return Name.
   */
  public final String getName(){ return m_name; }
  
  /**
   * <p>
   *   Sets name on sub case.
   * </p>
   * @param name Name.
   */
  public final void setSubcase(String name){ m_subcase=name; }
  
  /**
   * <p>
   *   Gets sub case name.
   * </p>
   * @return Name.
   */
  public final String getSubcase(){ return m_subcase; }
  
  /**
   * <p>
   *   Sets name on meta case.
   * </p>
   * @param name Name.
   */
  public final void setMetacase(String name){ m_metacase=name; }
  
  /**
   * <p>
   *   Gets meta case name.
   * </p>
   * @return Name.
   */
  public final String getMetacase(){ return m_metacase; }
  
  /**
   * <p>
   *   Gets name on case that include
   *   {@link #getName()},
   *   {@link #getSubcase()} if is given and
   *   {@link #getMetacase()} if is given.
   * </p>
   * @return Full name.
   */
  public final String getFullName()
  {
    StringBuilder sb=new StringBuilder();
    
    sb.append("name : '").append(m_name).append("'");
    
    if (m_subcase!=null) 
      sb.append(" sub-case : '").append(m_subcase).append("'");
    
    if (m_metacase!=null)
      sb.append(" meta-case : '").append(m_metacase).append("'");
    
    return sb.toString();
  }
  
  /**
   * <p>
   *   Sets keywords.
   * </p>
   * @param keywords Keywords.
   */
  public final void setKeywords(Input keywords){ m_keywords=keywords; }
  
  /**
   * <p>
   *   Gets keywords.
   * </p>
   * @return Keywords or {@code null} if not sat.
   */
  public final Input getKeywords(){ return m_keywords; }
  
  @Override
  public String toString() 
  {
    StringBuilder sb=new StringBuilder();
    sb.append("case: ").append(getFullName()).append(", keywords=")
      .append(m_keywords);
    return sb.toString();
  }
  
}
